#ifndef WIDGETSCRIPTTREE_H
#define WIDGETSCRIPTTREE_H

#include <QWidget>
#include <QListWidgetItem>

namespace Ui {
class WidgetScriptTree;
}

class WidgetScriptTree : public QWidget
{
    Q_OBJECT

public:
    explicit WidgetScriptTree(QWidget *parent = nullptr);
    ~WidgetScriptTree();

    /**
     * @brief 加载用户脚本列表
     */
    void LoadScript();

signals:
    void sig_scriptSelected(int index);

protected:
    void dragEnterEvent(QDragEnterEvent *event) override;
    void dropEvent(QDropEvent *event) override;

private slots:
    void on_listWidget_customContextMenuRequested(const QPoint &pos);

    void listWidget_currentRowChanged(int currentRow);
    void listWidget_itemChanged(QListWidgetItem *item);

    void actionNew_triggered();
    void actionDelete_triggered();
    void actionRename_triggered();
    void actionMoveUp_triggered();
    void actionMoveDown_triggered();

private:
    QListWidgetItem* addItem(int index);

private:
    Ui::WidgetScriptTree *ui;
    QMenu* _contextMenu;
    QAction* _actionNew;
    QAction* _actionDelete;
    QAction* _actionRename;
    QAction* _actionMoveUp;
    QAction* _actionMoveDown;
};

#endif // WIDGETSCRIPTTREE_H
